<?php

class MathPlus
{
	public static function decst ($number) {
		$string = '';
		while ($number != 0) {
			$linshi = $number % 62;
			if (($linshi>=10) && ($linshi<36)) {$string.= chr($linshi+55);}
			elseif (($linshi>=36) && ($linshi<62)) {$string.= chr($linshi+61);}
			else $string.= $linshi;
			$number = intval($number/62);
		}
		return strval(strrev($string));
	}
	
	public static function stdec($string) {
		$shu=0;
		for ($i=0; $i<=strlen($string)-1; $i++) {
			$linshi = substr($string, $i, 1);
			if (ord($linshi)<=57) {
				$shu+=$linshi*pow(62,strlen($string)-$i-1);
			} elseif ((ord($linshi)>=65) && (ord($linshi)<=90)) {
				$shu+= (ord($linshi)-55)*pow(62,strlen($string)-$i-1);
			} else {
				$shu+= (ord($linshi)-61)*pow(62,strlen($string)-$i-1);
			}
		}
		return $shu;
	}
}